package it.polimi.traveldream.web.beans;

import it.polimi.traveldream.ejb.invito.InvitoDTO;
import it.polimi.traveldream.ejb.invito.InvitoMgr;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean (name="invitoBean")
@RequestScoped
public class InvitoBean {
	
	@EJB
	private InvitoMgr invitoMgr;

	private InvitoDTO nuovoInvito;
	
	public InvitoBean(){
		nuovoInvito = new InvitoDTO();
	}
	
	public String invita(int idAcquisto){
		
		//DEBUG ONLY
		System.out.println(idAcquisto);
		//
		nuovoInvito.setMittente("asd");
		invitoMgr.save(nuovoInvito, idAcquisto);
		return "nuovoInvito?faces-redirect=true";
	}

	public InvitoMgr getInvitoMgr() {
		return invitoMgr;
	}

	public void setInvitoMgr(InvitoMgr invitoMgr) {
		this.invitoMgr = invitoMgr;
	}

	public InvitoDTO getNuovoInvito() {
		return nuovoInvito;
	}

	public void setNuovoInvito(InvitoDTO nuovoInvito) {
		this.nuovoInvito = nuovoInvito;
	}	
	
}